﻿import org.aswing.*;
import org.aswing.plaf.custom.css.*;
import org.aswing.plaf.custom.parser.*;


class CSSTest extends JFrame{
	
	public static function main(Void):Void{
		var app:CSSTest = new CSSTest();
		app.setLocation (2, 2);		
		app.setSize (796, 596);
		app.setDragable(false);
		app.setResizable(false);
		app.setClosable(false)
		app.show ();
	}
	
	private var editor:JTextArea;
	private var logger:JTextArea;	
	
	function CSSTest(){
		super (_root, true);
		setTitle( "CSS Tracer");
		editor = new JTextArea();
		editor.setText("button{\n\tfont:courier;\n\tfont-size:10;\n}");
		editor.setPreferredSize(600,300);
		logger = new JTextArea();
		logger.setEditable(false);
		editor.setPreferredSize(600,150);
		var panel:JPanel = new JPanel();
		panel.setLayout(new BorderLayout());
		panel.append(new JScrollPane(editor),BorderLayout.NORTH);
		panel.append(new JScrollPane(logger),BorderLayout.CENTER);
		var btn:JButton = new JButton("Read CSS");
		panel.append(btn,BorderLayout.SOUTH);
		getContentPane().append(panel, BorderLayout.EAST)
		btn.addEventListener(JButton.ON_PRESS,traceCSS,this);
	}
	
	function traceCSS(){		
		this.logger.setText(CSSParser.parseDocument(this.editor.getText()).toString());	
		this.logger.appendText("\nPARSING LOG:");
		this.logger.appendText(ParserLog.getInstance().logMessage)
	}
}
